# encoding = utf-8
class ApplicationController < ActionController::Base
  protect_from_forgery

  def amount(carts, voucher = nil)
    amo = 0
    carts.each do |cart|
      product = cart.product
      amo+=(product.price*cart.number*product.discount/10)
    end
    if !voucher.nil?
      return amo-voucher.money
    end
    return amo
  end
  
end
